<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../css/ladder.css">
</head>
<body>

<div style="width: 98%;margin: 5px auto 0">

    <div style="margin-top: 5px;border-bottom: 1px solid #ccc;padding: 3px 10px;">
        <i class="iconfont" style="font-size: 20px;">&#xe77d;</i>
        <span style="font-size: 14px;">数据库明文密码处理</span>
    </div>
    <div style="padding: 3px 10px;margin-top: 2px;border-bottom: 1px dotted #663300;">
        <div>
            <input class="w200" id="oldpassword">
            <button id="countpassword">加密</button>
            <input class="w200 fr" id="newpassword">
        </div>
    </div>
</div>
<div style="width: 98%;margin: 5px auto 0">

    <div style="margin-top: 5px;border-bottom: 1px solid #ccc;padding: 3px 10px;">
        <i class="iconfont" style="font-size: 20px;">&#xe77d;</i>
        <span style="font-size: 14px;">参数明文处理</span>
    </div>
    <div style="padding: 3px 10px;margin-top: 2px;border-bottom: 1px dotted #663300;">
        <div>
            正文:<input class="w150" id="encrypt_content">
            密钥:<input class="w150" id="encrypt_key">
            <button id="encryptbtn">加密</button>
            <button id="decrypttbtn">解密</button>
            <textarea id="encryptresult" style="clear: both;width: 100%;height: 80px;"></textarea>
        </div>
    </div>
</div>
<div style="width: 98%;margin: 5px auto 0">

    <div style="margin-top: 5px;border-bottom: 1px solid #ccc;padding: 3px 10px;">
        <i class="iconfont" style="font-size: 20px;">&#xe77d;</i>
        <span style="font-size: 14px;">通用站点配置设置</span>
    </div>
    <div style="padding: 3px 10px;margin-top: 2px;border-bottom: 1px dotted #663300;">
        <div>
            <span class="inline-block w100 text-center">站点地址</span><input class="w250" id="siteurl">
            <br>
            <span class="inline-block w100 text-center">站点密钥</span><input class="w250" id="token">
            <br>
            <span class="inline-block w100 text-center">模版表位置</span><input class="w250" id="templatetableName">
            <span style="color: #CC0033">(developer.sys_data)</span>
            <br>
            <span class="inline-block w100 text-center">数据库服务器</span><input class="w250" id="server">
            <br>
            <div class="text-center w300" style="margin-top: 3px">
                <button  id="redefaultbasesettings" class="h25 w150">重置站点模版配置</button>
            </div>

        </div>
    </div>
</div>
<script src="../lib/require.js"></script>
<script>
    require(["ladder"],function () {
        $("#countpassword").click(function () {
            $("#newpassword").val("");
            webajax(URLS.Exec,{tableName:"passwordEncrypt",param:{pToEncrypt:$("#oldpassword").val()}},function (result) {
                if(result.statusCode==200){
                    $("#newpassword").val(result.data);
                }
            })
        });
        $("#encryptbtn").click(function () {
            aes();
        });
        $("#decrypttbtn").click(function () {
            aes(1);
        })

        function aes(option){
            var key=$("#encrypt_key").val();
            var content=$("#encrypt_content").val();
            var tableName="encryptByAES";
            if(option){
                tableName="decryptByAES";
                content=$("#encryptresult").val();
            }
            webajax(URLS.Exec,{tableName:tableName,param:{input:content,key:key}},function (result) {
                if(result.statusCode==200){
                    if(option){
                        $("#encrypt_content").val(result.data);
                    }else {
                        $("#encryptresult").val(result.data);
                    }

                }
            })
        }
    
        $("#redefaultbasesettings").click(function () {
            var url=$("#siteurl").val();
            var token=$("#token").val();
//            if()
//            webajax()


        });
        

        
        
    })
</script>
</body>
</html>